package com.meshnetics.gb.type.impl.zcl;

/**
 * WRITE DESCRIPTION HERE
 *
 * @author AKovylin
 */
public class BitmapEditor {
    private final Bitmap inner;

    public BitmapEditor(TypeBitmap type) {
        inner =(Bitmap) type.createValue(new byte[type.getByteSize()]); // new array filled with zeroes always
    }

    public BitmapEditor(Bitmap bitmap) {
        this.inner = (Bitmap) ((TypeBitmap) bitmap.getType()).createValue(bitmap.bytesValue());
    }

    public boolean getBit(int bit) {
        return inner.getBit(bit);
    }

    public void setBit(int bit, boolean on) {
        inner.setBit(bit, on);
    }

    public int getBits(int fromBit, int toBit) {
        return inner.getBits(fromBit, toBit);
    }

    public void setBits(int fromBit, int toBit, int bits) {
        inner.setBits(fromBit, toBit, bits);
    }

    public Bitmap create() {
        return (Bitmap) ((TypeBitmap) inner.getType()).createValue(inner.bytesValue());
    }

}
